package com.zoe.onelink.core.util;

import com.zoe.onelink.core.nfs.storage.NfsApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.PostConstruct;
import java.io.IOException;
import java.io.InputStream;

/**
 * <p>标题: </p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2022</p>
 * <p>公司: 智业软件股份有限公司</p>
 *
 * @version: 1.0
 * @author: ruansheng
 * @date: 2022-04-22
 */
public class NfsUtil {

    @Autowired
    private NfsApi<String> nfsApi;
    private static NfsUtil self;

    @PostConstruct
    public void init() {
        self = this;
    }

    public static String uploadFile(MultipartFile file, String filePath) throws IOException {
        return self.nfsApi.uploadFile(file.getInputStream(), filePath);
    }

    public static InputStream downloadFile(String filePath) {
        return self.nfsApi.downloadFile(filePath);
    }

}
